package com.chunxuan.langquan.base;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.multidex.MultiDex;

import com.baidu.mapapi.SDKInitializer;
import com.chunxuan.langquan.support.util.GlideImageLoader;
import com.chunxuan.langquan.support.util.ScreenUtils;
import com.chunxuan.langquan.support.util.ToastUtilsLocal;
import com.chunxuan.langquan.wxapi.WXEntryActivity;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.view.CropImageView;
import com.ruitu.arad.AradApplication;
import com.ruitu.arad.AradApplicationConfig;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshFooter;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.DefaultRefreshFooterCreator;
import com.scwang.smart.refresh.layout.listener.DefaultRefreshHeaderCreator;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

public class MyApp extends AradApplication {

    // “00” – 银联正式环境
    // “01” – 银联测试环境，该环境中不发生真实交易
    public static final String unionPayMode = "00";
    @Override
    protected AradApplicationConfig appConfig() {
        return new AradApplicationConfig();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        SDKInitializer.initialize(getApplicationContext());
        CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(this);
        strategy.setAppChannel("myChannel");
        strategy.setAppVersion("1.0.0");
        strategy.setAppPackageName("com.chunxuan.langquan");
        CrashReport.initCrashReport(this, "2f43b7650c", false, strategy);
        initImageLoader();

        SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
            @NonNull
            @Override
            public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
                return new ClassicsHeader(context);
            }
        });
        SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
            @NonNull
            @Override
            public RefreshFooter createRefreshFooter(@NonNull Context context, @NonNull RefreshLayout layout) {
                return new ClassicsFooter(context);
            }
        });
        init();
    }
    private void init() {
        ToastUtilsLocal.init(this);
        ScreenUtils.init(this);
    }
    public static void initImageLoader() {
        ImagePicker imagePicker = ImagePicker.getInstance();
        imagePicker.setImageLoader(new GlideImageLoader());   //设置图片加载器
        imagePicker.setShowCamera(true);  //显示拍照按钮
        imagePicker.setCrop(true);        //允许裁剪（单选才有效）
//        imagePicker.setFreeCrop(true, FreeCropImageView.CropMode.FREE);//新版添加,自由裁剪，优先于setCrop
        imagePicker.setSaveRectangle(true); //是否按矩形区域保存
        imagePicker.setSelectLimit(9);    //选中数量限制
        imagePicker.setStyle(CropImageView.Style.RECTANGLE);  //裁剪框的形状
        imagePicker.setFocusWidth(800);   //裁剪框的宽度，仅对crop有效，对isFreeCrop无效
        imagePicker.setFocusHeight(800);  //裁剪框的高度，仅对crop有效，对isFreeCrop无效
        imagePicker.setOutPutX(1000);//保存文件的宽度。单位像素，仅对crop有效，对isFreeCrop无效
        imagePicker.setOutPutY(1000);//保存文件的高度。单位像素，仅对crop有效，对isFreeCrop无效
//        imagePicker.setIToaster(this, new InnerToaster.IToaster());//设置吐司代理,保持lib与app中吐司风格一致
    }
}
